/* GUI CONVERTED from wowamta.p (converter v1.76) Wed May 22 11:24:16 2002 */
/* wowamta.p - WORK ORDER BILL MAINTENANCE                                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.10 $                                                          */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 8.5      LAST MODIFIED: 05/07/96   BY: *J0LS* Kieu Nguyen        */
/* REVISION: 8.5      LAST MODIFIED: 03/24/97   BY: *G2KT* Russ Witt          */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 03/06/00   BY: *N05Q* Vincent Koh        */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KC* myb                */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.9        BY: Katie Hilbert        DATE: 04/01/01 ECO: *P008*   */
/* $Revision: 1.10 $    BY: Jean Miller          DATE: 05/17/02 ECO: *P05V*   */
/* hk-s-009         modified by *mage*           date 11/12/03                */ 
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i }
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

define shared variable part like wo_part.
define shared variable nbr like wod_nbr.
define shared variable lot like wod_lot.
define shared frame a.
define shared variable undo_all like  mfc_logical initial no no-undo.

define shared variable desc1 like pt_desc1.
define shared variable desc2 like pt_desc1.
define shared variable wodesc1 like pt_desc1.
define shared variable wodesc2 like pt_desc1.
define shared variable detail_all like soc_det_all.
define shared variable status_name like wo_status format "x(12)".
define shared variable wod_recno as recid.

/* DISPLAY SELECTION FORM */

/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A
/*mage del start ****************************************************************** 
FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
wo_nbr         colon 25
   wo_lot         colon 50
   part           colon 25
   wodesc1                 no-label at 47 no-attr-space
   status_name    colon 25
   wodesc2                 no-label at 47 no-attr-space
   skip(1)
   wod_part       colon 25 label "Component Item"
   desc1                   no-label at 47 no-attr-space
   wod_op         colon 25
   desc2                   no-label at 47 no-attr-space
   skip(1)
   wod_qty_req    colon 25
   wod_bom_qty    colon 55 label "Qty Per Unit"
   wod_qty_all    colon 25
   wod_bom_amt    colon 55 label "Unit Cost" format ">>>>,>>>,>>9.99<<<"
   wod_qty_pick   colon 25
   detail_all     colon 25
   wod_qty_iss    colon 25
   skip(1)
   wod_site       colon 25
   wod_loc        colon 25
   wod_critical   colon 25 label "Key Item"
   wod_iss_date   colon 25
   wod_deliver    colon 25
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/


/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME

*mage del start ******************************************************************/

/*mage add start **********************************************************/
FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
wo_nbr      colon 15
   wo_lot      colon 45 
    wo_status  COLON 65
   wo_part     colon 15 
   desc1       at 45 no-label       
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME

/*mage add end **********************************************************/



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

/* DISPLAY */
view frame a.

undo_all = yes.

mainloop:
do with frame a:

   ststatus = stline[1].
   status input ststatus.

   prompt-for wo_nbr wo_lot
   editing:

      if frame-field = "wo_nbr" then do:
         nbr = input wo_nbr.
         /* FIND NEXT/PREVIOUS RECORD */
         {mfnp.i wo_mstr wo_nbr wo_nbr wo_nbr wo_nbr wo_nbr}
      end.

      else if frame-field = "wo_lot" then do:
         /* FIND NEXT/PREVIOUS RECORD */
         if nbr = "" then do:
            {mfnp.i wo_mstr wo_lot wo_lot wo_lot wo_lot wo_lot}
         end.
         else do:
            {mfnp01.i wo_mstr wo_lot wo_lot nbr wo_nbr wo_nbr}
         end.
      end.

      else do:
         readkey.
         apply lastkey.
      end.
      

      if recno <> ? then do:

         assign
            part = ""
            wodesc1 = ""
            wodesc2 = ""
            status_name = ""
            part = wo_part.

         {mfwostat.i status_name wo_status}

         find pt_mstr where pt_part = wo_part no-lock no-error.
         IF available pt_mstr then
         assign
             wodesc1 = pt_desc1
             wodesc2 = pt_desc2.

 /*mage         find first wod_det no-lock where wod_nbr = wo_nbr
                                       and wod_lot = wo_lot
         no-error.
*mage **********************************************************/

         assign
            desc1 = ""
            desc2 = "".

/*mage         if not available wod_det then clear frame a. 
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title. ******/

/*mage         display wo_nbr wo_lot part wodesc1 wodesc2 status_name. ****/

/*mage*/         display wo_nbr wo_lot wo_status wo_part wodesc1 @  desc1 . 

/*mage***          if available wod_det then do:

            find pt_mstr where pt_part = wod_part no-lock no-error.

            if available pt_mstr then
            assign
               desc1 = pt_desc1
               desc2 = pt_desc2.

            /* SEE IF DETAIL ALLOCATIONS */
            if can-find(first lad_det where lad_dataset = "wod_det"
               and lad_nbr = wod_lot and lad_line = string(wod_op)
               and lad_part = wod_part)
            then
               detail_all = yes.
            else
               detail_all = no.

/* mage             display
               wod_part
               wod_op
               desc1 desc2 wod_qty_req
               wod_bom_qty wod_bom_amt
               wod_qty_all wod_qty_pick wod_qty_iss
               wod_critical
               wod_iss_date wod_deliver
               detail_all wod_site wod_loc.  **********/

         end. /* IF AVAILABLE WO_DET */
*mage***********************************************/

      end. /* IF RECNO <> ? */

   end. /* PROMPT-FOR...EDITING */

   if input wo_nbr = "" and input wo_lot = "" then undo, retry.
   assign
      nbr = input wo_nbr
      lot = input wo_lot.

   if nbr <> "" and lot <> "" then
      find wo_mstr where wo_nbr = nbr and wo_lot = lot no-lock no-error.
   if not available wo_mstr then
      if nbr = "" and lot <> "" then
         find wo_mstr where wo_lot = lot no-lock no-error.
   if not available wo_mstr then
      if nbr <> "" and lot = "" then
         find first wo_mstr where wo_nbr = nbr no-lock no-error.
   if nbr <> "" or lot <> "" then
      if not available wo_mstr then do:
         {pxmsg.i &MSGNUM=510 &ERRORLEVEL=3} /*  WORK ORDER DOES NOT EXIST.*/
         next-prompt wo_nbr.
         if nbr = "" then next-prompt wo_lot.
         undo, retry.
      end.

   /* SKIP WORK ORDERS CREATED BY CALL ACTIVITY RECORDING */
   if wo_fsm_type = "FSM-RO" then do:
      {pxmsg.i &MSGNUM=7492 &ERRORLEVEL=3}    /* FIELD SERVICE CONTROLLED */
      next-prompt wo_nbr.
      if nbr = "" then next-prompt wo_lot.
      undo, retry.
   end.

   /* SKIP WORK ORDERS CREATED FOR PROJECT ACTIVITY RECORDING */
   if wo_fsm_type = "PRM" then do:
      {pxmsg.i &MSGNUM=3426 &ERRORLEVEL=3}    /* CONTROLLED BY PRM MODULE */
      next-prompt wo_nbr.
      if nbr = "" then next-prompt wo_lot.
      undo, retry.
   end.

   {gprun.i ""gpsiver.p"" "(input wo_site, input ?, output return_int)"}
/*GUI*/ if global-beam-me-up then undo, leave.

   if return_int = 0 then do:
      /* USER DOES NOT HAVE ACCESS TO SITE XXXX */
      {pxmsg.i &MSGNUM=2710 &ERRORLEVEL=3 &MSGARG1=wo_site}
      undo , retry.
   end.

   assign
      part = ""
      status_name = ""
      wodesc1 = ""
      wodesc2 = "".

   if available wo_mstr then do:
      assign
         lot = wo_lot
         part = wo_part
         nbr = wo_nbr.
      find pt_mstr where pt_part = wo_part no-lock no-error.
      if available pt_mstr then
      assign
         wodesc1 = pt_desc1
         wodesc2 = pt_desc2.
      {mfwostat.i status_name wo_status}
   end.

 /*mage  display wo_nbr wo_lot  part wodesc1 wodesc2 status_name. */
/*mage*/         display wo_nbr wo_lot wo_status wo_part wodesc1 @  desc1 WITH FRAME a . 
/*mage************
   find first wod_det no-lock where wod_nbr = wo_nbr
      and wod_lot = wo_lot
   no-error.

   assign
      desc1 = ""
      desc2 = "".

   if available wod_det then do:

      find pt_mstr where pt_part = wod_part no-lock no-error.

      if available pt_mstr then
      assign
         desc1 = pt_desc1
         desc2 = pt_desc2.

      display
         wod_part
         wod_op
         desc1 desc2
         wod_qty_req
         wod_bom_qty
         wod_bom_amt
         wod_qty_all
         wod_qty_pick
         wod_qty_iss
         wod_site
         wod_loc
         wod_critical
         wod_iss_date
         wod_deliver.
   end.

*mage**********************************************/

   if lookup(wo_status,"P,F,B,C,") <> 0
   then do:
      {pxmsg.i &MSGNUM=523 &ERRORLEVEL=2}
      /* MODIFICATION TO PLANNED AND FIRM PLANNED COMPONENTS NOT ALLOWED */
   end.

   if index("1234",wo_joint_type) <> 0 then do:
      /* WORK ORDER BILLS & ROUTINGS CANNOT EXIST FOR CO-BY-PRODUCTS */
      {pxmsg.i &MSGNUM=6526 &ERRORLEVEL=3}
      undo, retry.
   end.

   undo_all = no.
end.
